﻿#region ExcuteHalconProcParameter_Binary.cs
// ============================================================================
// This region will be filled automatically with data if you are working
// for example with Microsoft SourceSafe
//
// Purpose:          
// Specifics: 
// 
// Creation date:    2024/1/3 21:32:51
// Created by:       hao.chen
//
// $Author:        $
// $Date:          $
// $Revision:      $
// $History:       $
// $NoKeywords:    $
// 
// Copyright:      © 2024 YourCompanyName
//                 All Rights Reserved
// ============================================================================
#endregion

using NeuroCheck.PlugInLib.Base;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

// TODO: Namespace - Modify the namespace to the project namespace
namespace CLVisionHalconNC620
{
    /// <summary>This file contains the code is necessary to serialize and deserialize the parameters
    /// of the plug-in check function "ExcuteHalconProc". This data are the base for storing and loading
    /// the plug-in check function parameters in the binary CHR-file (check routine file).
    /// </summary>
    /// <remarks>It is recommended to serialize only necessary data and none that is created at runtime.
    /// </remarks>
    [Serializable]
    public partial class ExcuteHalconProcParameter
    {
     

        /// <summary>Current version of this class.
        /// History:
        /// 6.2.0.0 | 2018-10-25 (TODO: BinarySerialization - Set the version and creation date of this class, example: 6.2.0.0 | 2018-10-25)
        /// </summary>
        /// <remarks>
        /// - May not be the version from AssemblyInfo.cs, otherwise each serializable class will have the same version.
        /// </remarks>
        public static Version m_CurrentVersion = new Version(6, 2, 0, 0);
        /// <summary>Version of this class that has been serialized.
        /// </summary>
        /// <remarks>
        /// - On initializing this class is the same version like current version.
        /// </remarks>
        public static Version m_SerializationVersion = m_CurrentVersion;

    

        /// <summary>Deserialization constructor.
        /// </summary>
        /// <param name="info">SerializationInfo.</param>
        /// <param name="context">StreamingContext.</param>
        /// <remarks>Please note that you have to deserialize every necessary parameter explicitly.
        /// </remarks>
        public ExcuteHalconProcParameter(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            m_SerializationVersion = (Version)info.GetValue("SerializationVersion", typeof(Version));

            // Verify the serialized class version
            // The minimum supported version is 6.2.0.0 and maximum the current version of this class. It is not the version from AssemblyInfo.cs.
            // This verification prevents the deserialization of data created by class version 6.2.1.0 if this code supports version 6.2.0.0 only.
            if ((m_SerializationVersion >= new Version(6, 2, 0, 0)) &&
                (m_SerializationVersion <= m_CurrentVersion))
            {
            
                _currentProcedureName = info.GetString("CurrentProcedureName");
                _ls_iconic_Input = info.GetValue("Ls_iconic_Input", typeof(List<(string, string, string)>)) as List<(string, string, string)>;
                _ls_iconic_Output = info.GetValue("Ls_iconic_Output", typeof(List<(string, string, string)>)) as List<(string, string, string)>;
                _ls_control_Input = info.GetValue("Ls_control_Input", typeof(List<(string, string, string)>)) as List<(string, string, string)>;
                _ls_control_Output = info.GetValue("Ls_control_Output", typeof(List<(string, string, string)>)) as List<(string, string, string)>;
                _ls_cfg_Par = info.GetValue("Ls_cfg_Par", typeof(List<(string, string, List<string>, string)>)) as List<(string, string, List<string>, string)>;
                _dic_proceduresPar = info.GetValue("Dic_proceduresPar", typeof(Dictionary<string, (List<(string, string, string)>, List<(string, string, string)>, List<(string, string, string)>, List<(string, string, string)>, List<(string, string, List<string>, string)>)>))
                    as Dictionary<string, (List<(string, string, string)>, List<(string, string, string)>, List<(string, string, string)>, List<(string, string, string)>, List<(string, string, List<string>, string)>)>;
            } // eof if
            else
            {
                string message = String.Format(Properties.GlobalResources.strVersionIsNotSupported,
                                               Properties.ExcuteHalconProcResources.strCheckFunctionName,
                                               m_SerializationVersion.ToString(),
                                               m_CurrentVersion.ToString());
                NcPIUserException newEx = new NcPIUserException(message);
                throw newEx;

            } // eof else
        }

   

        /// <summary>Populates a SerializationInfo with the data needed to serialize the target object.
        /// </summary>
        /// <param name="info">SerializationInfo.</param>
        /// <param name="context">StreamingContext.</param>
        /// <remarks>Please note that you have to serialize every necessary parameter explicitly.
        /// </remarks>
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            base.GetObjectData(info, context);
            m_SerializationVersion = m_CurrentVersion;
            info.AddValue("SerializationVersion", m_SerializationVersion);
      
            info.AddValue("CurrentProcedureName", _currentProcedureName);
            info.AddValue("Ls_iconic_Input", _ls_iconic_Input);
            info.AddValue("Ls_iconic_Output", _ls_iconic_Output);
            info.AddValue("Ls_control_Input", _ls_control_Input);
            info.AddValue("Ls_control_Output", _ls_control_Output);
            info.AddValue("Ls_cfg_Par", _ls_cfg_Par);
            info.AddValue("Dic_proceduresPar", _dic_proceduresPar);
        }

    

    } // end of class
} // end of namespace